<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Lang" content="en">
<meta name="author" content="">
<meta http-equiv="Reply-to" content="@.com">
<meta name="generator" content="PhpED 6.0">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="creation-date" content="06/01/2011">
<meta name="revisit-after" content="15 days">
<title>Untitled</title>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.8.18/themes/ui-lightness/jquery-ui.css">

<style type="text/css">
    .clear{
        clear: both;
    }
        .container{
            /*background-color: yellow;*/
            width: 1640px;
        }
        .fleft{
            float: left;
        }
        .colbox-story{
            width: 174px;
            margin-right: 2px;
            /*border: 1px solid silver;*/
            display: table;
        }
        .colbox{
            width: 355px;
            margin-right: 2px;
            /*border: 1px solid silver;*/
        }
        .colboxtop{
            text-align: center;
        }
        .colboxtop h3{
            padding: 0;
            margin: 5px 0;
        }
        .column { width: 352px; float: left; padding-bottom: 10px;
            /*background-color: #D5FFE7;*/
            margin: 2px;
        }
        .portlet { margin: 0 2px 2px 2px; width:170px; }
        .portlet-header { margin: 0.3em; padding-bottom: 4px; padding-left: 0.2em; }
        .portlet-header .ui-icon { float: right; }
        .portlet-content { padding: 0.4em; /*display: none;*/ }
        .ui-sortable-placeholder { border: 1px dotted black; visibility: visible !important; height: 50px !important; }
        .ui-sortable-placeholder * { visibility: hidden; }
        
        .todo .portlet-header{
            background-color: #FCC74B;
        }
        .inprocess .portlet-header{
            background-color: #D5FFE7;
        }
        .done .portlet-header{
            background-color: #B6FF48;
        }
</style>

<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<script src="https://raw.github.com/furf/jquery-ui-touch-punch/master/jquery.ui.touch-punch.min.js"></script>

<script>
var $CurentSortable;

$(document).ready(function(){
    $( "#dialog-edit" ).dialog({
        autoOpen: false,
        //show: "blind",
        hide: "explode",
        modal: true
    });
    
    $( "#dialog-feedback" ).dialog({
        autoOpen: false,
        //show: "blind",
        hide: "explode",
        modal: true,
        buttons: {
          "Delete all items": function() {
              $CurentSortable.sortable('cancel');
            $( this ).dialog( "close" );
          },
          Cancel: function() {
            $( this ).dialog( "close" );
          }
        }
    });
    
    $( "#dialog" ).dialog({
        autoOpen: false,
        //show: "blind",
        hide: "explode",
        modal: true,
        buttons: {
          "Delete all items": function() {
            $( this ).dialog( "close" );
          },
          Cancel: function() {
            $( this ).dialog( "close" );
          }
        }
    });
  
    $(".btnEdit").click(function(){
         $( "#dialog" ).dialog( "open" );
         return false;
    });
    
    $(".edit-task").click(function(){
        $("#dialog-edit").dialog("open");
    });
});

$(function() {
  $( ".column" ).sortable({
    connectWith: ".column",
    start: function(event, ui) {
        //var id = $(this).attr('id');
        //alert(id);
        //alert(event.attr('id'));
    },
    
    stop: function(event, ui) { 
        var $curentElement = ui.item;//the div dang dc thuc thi
        var colindex = $curentElement.attr("colindex");
        var rowitem = $curentElement.attr("rowitem");
        var newColindex = $curentElement.parent().attr("colindex");
        var newRowitem = $curentElement.parent().attr("rowitem");
        var flag = true;
        if(rowitem == newRowitem ){
            if(colindex == "done" && newColindex == "inprocess"){
                $CurentSortable = $(this);
                $( "#dialog-feedback" ).dialog( "open" );
            }
        }else{
            $(this).sortable('cancel');
        }
        
        $curentElement.removeClass(colindex);
        $curentElement.addClass(newColindex);
        $curentElement.attr("colindex",newColindex);
    }
  });

  $( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
    .find( ".portlet-header" )
      //.addClass( "ui-widget-header ui-corner-all" )
      .addClass( "ui-corner-all" )
      .prepend( "<span class='ui-icon ui-icon-minusthick'></span>")
      .end()
    .find( ".portlet-content" );

  $( ".portlet-header .ui-icon" ).click(function() {
    $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" );
    $( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle();
  });

  $( ".column" ).disableSelection();
});
</script>
</head>
<body style="cursor: auto;">
    <div class="container">
    <table border="1" cellspacing="0">
<thead>
    <tr>
        <th>Story</th>
        <th>To do</th>
        <th>In process</th>
        <th>Completed</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td valign="top">
            <div class="colbox-story fleft">
                <div class="column-story" colindex="todo" rowitem="0">
                    <div class="portlet todo" colindex="todo" rowitem="0" id="1">
                        <div class="portlet-header">Task 1</div>
                        <div class="portlet-content">
                            Lorem ipsum dolor sit amet, consectetuer adipiscing elit
                            <button class="btnEdit">Edit</button>
                        </div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
        
        <td valign="top">
            <div class="colbox fleft">
                <div class="column" colindex="todo" rowitem="0">
                    <div class="portlet todo fleft" colindex="todo" rowitem="0" id="1">
                        <div class="portlet-header">Task 1</div>
                        <div class="portlet-content">
                            Lorem ipsum dolor sit amet, consectetuer adipiscing elit
                            <button class="edit-task">Edit</button>
                        </div>
                    </div>
                    <div class="portlet todo fleft" colindex="todo" rowitem="0" id="2">
                    <div class="portlet-header">Task 2</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
        
        <td valign="top">
            <div class="colbox fleft">
                <div class="column" colindex="inprocess" rowitem="0">
                    <div class="portlet inprocess fleft" colindex="inprocess" rowitem="0" id="4">
                    <div class="portlet-header">Task 4</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    
                    <div class="portlet inprocess fleft" colindex="inprocess" rowitem="0" id="5">
                    <div class="portlet-header">Task 5</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
        
        <td valign="top">
            <div class="colbox fleft">
                <div class="column" colindex="done" rowitem="0">
                    <div class="portlet fleft done" colindex="done" rowitem="0" id="5">
                    <div class="portlet-header">Task 6</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    
                    <div class="portlet fleft done" colindex="done" rowitem="0" id="5">
                    <div class="portlet-header">Task 7</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
    </tr>
        <!-- ------------------------------------------------------------ -->
    <tr>
        <td valign="top">
            <div class="colbox-story fleft">
                <div class="column-story" colindex="todo" rowitem="1">
                    <div class="portlet fleft todo" colindex="todo" rowitem="1" id="1">
                    <div class="portlet-header">Task 1</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
        
        <td valign="top">
            <div class="colbox fleft">
                <div class="column" colindex="todo" rowitem="1">
                    <div class="portlet fleft todo" colindex="todo" rowitem="1" id="1">
                    <div class="portlet-header">Task 1</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    <div class="portlet fleft todo" colindex="todo" rowitem="1" id="2">
                    <div class="portlet-header">Task 2</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
        
        <td valign="top">
            <div class="colbox fleft">
                <div class="column" colindex="inprocess" rowitem="1">
                    <div class="portlet fleft inprocess" colindex="inprocess" rowitem="1" id="4">
                    <div class="portlet-header">Task 4</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    
                    <div class="portlet fleft inprocess" colindex="inprocess" rowitem="1" id="5">
                    <div class="portlet-header">Task 5</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
        
        <td valign="top">
            <div class="colbox fleft">
                <div class="column" colindex="done" rowitem="1">
                    <div class="portlet fleft done" colindex="done" rowitem="1" id="5">
                    <div class="portlet-header">Task 6</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    
                    <div class="portlet fleft done" colindex="done" rowitem="1" id="5">
                    <div class="portlet-header">Task 7</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </td>
    </tr>
</tbody>
    </table>
    </div>
    
    <div id="dialog" title="Basic dialog">
        <p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
    </div>

    <div id="dialog-feedback" title="Feedback">
        <p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
    </div>
    
    <div id="dialog-edit" title="edit">
        <form action="" method="POST">
            <textarea cols="30" rows="4"></textarea>
            <button type="submit">Save</button>
        </form>
    </div>
      
</body>
</html>
